package com.serial.socket;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.serial.socket.callBack.ForegroundCallbacks;

public class WsApplication extends Application {
    private static Application context;

    @Override
    public void onCreate() {
        super.onCreate();
        initAppStatusListener();
        context = this;
    }


    /**
     * 初始化应用前后台状态监听
     */
    private void initAppStatusListener() {
        ForegroundCallbacks.init(this).addListener(new ForegroundCallbacks.Listener() {
            @Override
            public void onBecameForeground() {

                Log.i("ApplicationTAG","应用回到前台调用重连方法");
                WsManager.getInstance().reconnect();
            }


            @Override
            public void onBecameBackground() {

            }
        });
    }

    public static Context getContext() {
        return context;
    }

}
